import service from '@/utils/request'
import { AxiosPromise } from 'axios'
import { LoginData, LoginResult, CaptchaResult } from './types'

/**
 * 登录API
 *
 * @param data {LoginData}
 * @returns
 */
export function loginApi(
  data: LoginData
): AxiosPromise<IResponse<LoginResult>> {
  return service.request({
    url: '/sysm/auth/doLogin',
    method: 'post',
    data: data,
  })
}

/**
 * 注销API
 */
export function logoutApi(): AxiosPromise<IResponse> {
  return service.request({
    url: '/sysm/auth/logout',
    method: 'delete',
  })
}

/**
 * 获取验证码
 */
export function getCaptchaApi(): AxiosPromise<IResponse<CaptchaResult>> {
  return service.request({
    url: '/api/v1/auth/captcha',
    method: 'get',
  })
}
